<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试finally</title>
</head>
<body>
  <script src="./Promise.js"></script>

  <!-- 
    finally(onFinal)
      无论当前promise是成功还是失败, onFinal都会执行, onFinal不接收参数
      finally也是返回一个新的promise, 结果状态由当前promise的结果状态决定
   -->
  <script>
    new Promise((resolve, reject) => {
      // resolve(1)
      // reject(2)
    }).finally(() => { 
      console.log('onFinal')
    }).then(
      value => {
        console.log('onResolved', value)
      },
      reason => {
        console.log('onRejected', reason)
      }
    )
  </script>
</body>
</html>